<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>‘ z
<div>
    <h1>身体质量指数测试</h1>
    <input type="text" placeholder="请输入身高(米)" v-model="h">
    <input type="text" placeholder="请输入体重(公斤)" v-model="w">
    <input type="button" value="开始测试" @click="f()">
    <h3>测试结果:{{info}}</h3>
</div>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            h: "", w: "",info:""
        },
        methods: {
            f() {
                //发出异步请求
                axios.get("/bmi?h=" + v.h + "&w=" + v.w).then(function (response) {
                    v.info=response.data;
                })
            }
        }
    })
</script>
</body>
</html>